#pragma once

#include <BaseTsd.h>

#ifdef _WIN64
typedef UINT64 MBuint;
typedef INT64 MBint;
#else
typedef UINT32 MBuint;
typedef INT32 MBint;
#endif


/**
  *	An MBTextureCoordinate is a UV-coordinate in texture space. A whole
  * texture can be addressed with coordinates from (0,0) to (1,1).
  */
class MBTextureCoordinate
{
public:
	/**
	  *	Constructs a new MBTextureCoordinate with a particular UV pair
	  */
	MBTextureCoordinate( const double &u = 0.0, const double &v = 0.0 ) :
		mU( u ),
		mV( v )
	{

	}

	/**
	  *	Compares the current MBTextureCoordinate object with another one.
	  * It returns true, if the current MBTextureCoordinate object is smaller
	  * than the other one, false otherwise. To determine which one of them is
	  * smaller, at first the u-value is compared, then the v-value.
	  *
	  * @param second the second MBTextureCoordinate object in the comparison
	  * @return true if the current MBTextureCoordinate object is smaller than the second one, false otherwise
	  */
	bool operator<( const MBTextureCoordinate &second ) const
	{
		if (mU < second.mU)
		{
			return true;
		}
		else if (mU > second.mU)
		{
			return false;
		}
		else
		{
			if (mV < second.mV)
			{
				return true;
			}

			return false;
		}
	}

	/**
	  *	Adds the current and the passed MBTextureCoordinate object together and returns the result.
	  * The current MBTextureCoordinate object is not modified.
	  *
	  * @param second MBTextureCoordinate object that is added to the current one
	  * @return sum of the current and the passed MBTextureCoordinate object
	  */
	MBTextureCoordinate operator+( const MBTextureCoordinate &second ) const
	{
		return MBTextureCoordinate( mU + second.mU, mV + second.mV );
	}

	/**
	  *	Adds the current and the passed MBTextureCoordinate object together and
	  * stores the result in the current one.
	  * The current MBTextureCoordinate object is modified by this operation.
	  *
	  * @param second MBTextureCoordinate object that is added to the current one
	  * @return reference to the current MBTextureCoordinate object
	  */
	MBTextureCoordinate &operator+=( const MBTextureCoordinate &second )
	{
		mU += second.mU;
		mV += second.mV;

		return *this;
	}

	/**
	  *	Subtracts the passed MBTextureCoordinate from the current one and returns the result.
	  * The current MBTextureCoordinate object is not modified.
	  *
	  * @param second MBTextureCoordinate object that is subtracted from the current one
	  * @return difference between the current and the passed MBTextureCoordinate object
	  */
	MBTextureCoordinate operator-( const MBTextureCoordinate &second ) const
	{
		return MBTextureCoordinate( mU - second.mU, mV - second.mV );
	}

	/**
	  *	Subtracts the passed MBTextureCoordinate object from the current one and
	  * stores the result in the current one.
	  * The current MBTextureCoordinate object is modified by this operation.
	  *
	  * @param second MBTextureCoordinate object that is subtracted from the current one
	  * @return reference to the current MBTextureCoordinate object
	  */
	MBTextureCoordinate &operator-=( const MBTextureCoordinate &second )
	{
		mU -= second.mU;
		mV -= second.mV;

		return *this;
	}

	/**
	  *	Scales the current MBTextureCoordinate object so that the coordinate
	  * ( u, v ) becomes ( value * u, value * v ) and returns the result.
	  * The current MBTextureCoordinate is not modified by this operation.
	  *
	  * @param value scale factor that is multiplied with the uv-coordinate
	  * @return product of value and the uv-coordinate
	  */
	MBTextureCoordinate operator*( const double &value ) const
	{
		return MBTextureCoordinate( mU * value, mV * value );
	}

	/**
	  *	Divides every component of the uv-coordinate by value so that ( u, v )
	  * becomes ( u / value, v / value ).
	  * The current MBTextureCoordinate is modified by this operation.
	  *
	  * @param value divisor that is used to divide u and v by it
	  * @return quotient of the uv-coordinate and value
	  */
	MBTextureCoordinate operator/( const double &value ) const
	{
		return MBTextureCoordinate( mU / value, mV / value );
	}

	/** u-coordinate of the 2D texture space coordinate */
	double mU;
	/** v-coordinate of the 2D texture space coordinate */
	double mV;
};